/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package co.com.entidades;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

/**
 *
 * @author 839398
 */
@Entity
@Table(name = "tbl_natillera_persona")
@NamedQueries({
    @NamedQuery(name = "TblNatilleraPersona.findAll", query = "SELECT t FROM TblNatilleraPersona t"),
    @NamedQuery(name = "TblNatilleraPersona.findByCodNatillera", query = "SELECT t FROM TblNatilleraPersona t WHERE t.tblNatilleraPersonaPK.codNatillera = :codNatillera"),
    @NamedQuery(name = "TblNatilleraPersona.findByDocPersona", query = "SELECT t FROM TblNatilleraPersona t WHERE t.tblNatilleraPersonaPK.docPersona = :docPersona"),
    @NamedQuery(name = "TblNatilleraPersona.findByFecha", query = "SELECT t FROM TblNatilleraPersona t WHERE t.fecha = :fecha"),
    @NamedQuery(name = "TblNatilleraPersona.findByFechaLiquidacion", query = "SELECT t FROM TblNatilleraPersona t WHERE t.fechaLiquidacion = :fechaLiquidacion"),
    @NamedQuery(name = "TblNatilleraPersona.findBySaldoAhorro", query = "SELECT t FROM TblNatilleraPersona t WHERE t.saldoAhorro = :saldoAhorro"),
    @NamedQuery(name = "TblNatilleraPersona.findBySaldoDeuda", query = "SELECT t FROM TblNatilleraPersona t WHERE t.saldoDeuda = :saldoDeuda")})
public class TblNatilleraPersona implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TblNatilleraPersonaPK tblNatilleraPersonaPK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "fecha")
    @Temporal(TemporalType.DATE)
    private Date fecha;
    @Column(name = "fecha_liquidacion")
    @Temporal(TemporalType.DATE)
    private Date fechaLiquidacion;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "saldo_ahorro")
    private BigDecimal saldoAhorro;
    @Column(name = "saldo_deuda")
    private BigDecimal saldoDeuda;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tblNatilleraPersona")
    private List<TblUsuarioPerfil> tblUsuarioPerfilList;
    @JoinColumn(name = "socio_refiere", referencedColumnName = "documento")
    @ManyToOne
    private TblPersona socioRefiere;
    @JoinColumn(name = "doc_persona", referencedColumnName = "documento", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private TblPersona tblPersona;
    @JoinColumn(name = "cod_natillera", referencedColumnName = "cod_natillera", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private TblNatillera tblNatillera;
    @JoinColumn(name = "estado", referencedColumnName = "cod_estado")
    @ManyToOne(optional = false)
    private TblEstado estado;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "tblNatilleraPersona")
    private TblUsuario tblUsuario;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tblNatilleraPersona")
    private List<TblCuota> tblCuotaList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tblNatilleraPersona")
    private List<TblPrestamo> tblPrestamoList;

    public TblNatilleraPersona() {
    }

    public TblNatilleraPersona(TblNatilleraPersonaPK tblNatilleraPersonaPK) {
        this.tblNatilleraPersonaPK = tblNatilleraPersonaPK;
    }

    public TblNatilleraPersona(TblNatilleraPersonaPK tblNatilleraPersonaPK, Date fecha) {
        this.tblNatilleraPersonaPK = tblNatilleraPersonaPK;
        this.fecha = fecha;
    }

    public TblNatilleraPersona(int codNatillera, String docPersona) {
        this.tblNatilleraPersonaPK = new TblNatilleraPersonaPK(codNatillera, docPersona);
    }

    public TblNatilleraPersonaPK getTblNatilleraPersonaPK() {
        return tblNatilleraPersonaPK;
    }

    public void setTblNatilleraPersonaPK(TblNatilleraPersonaPK tblNatilleraPersonaPK) {
        this.tblNatilleraPersonaPK = tblNatilleraPersonaPK;
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    public Date getFechaLiquidacion() {
        return fechaLiquidacion;
    }

    public void setFechaLiquidacion(Date fechaLiquidacion) {
        this.fechaLiquidacion = fechaLiquidacion;
    }

    public BigDecimal getSaldoAhorro() {
        return saldoAhorro;
    }

    public void setSaldoAhorro(BigDecimal saldoAhorro) {
        this.saldoAhorro = saldoAhorro;
    }

    public BigDecimal getSaldoDeuda() {
        return saldoDeuda;
    }

    public void setSaldoDeuda(BigDecimal saldoDeuda) {
        this.saldoDeuda = saldoDeuda;
    }

    public List<TblUsuarioPerfil> getTblUsuarioPerfilList() {
        return tblUsuarioPerfilList;
    }

    public void setTblUsuarioPerfilList(List<TblUsuarioPerfil> tblUsuarioPerfilList) {
        this.tblUsuarioPerfilList = tblUsuarioPerfilList;
    }

    public TblPersona getSocioRefiere() {
        return socioRefiere;
    }

    public void setSocioRefiere(TblPersona socioRefiere) {
        this.socioRefiere = socioRefiere;
    }

    public TblPersona getTblPersona() {
        return tblPersona;
    }

    public void setTblPersona(TblPersona tblPersona) {
        this.tblPersona = tblPersona;
    }

    public TblNatillera getTblNatillera() {
        return tblNatillera;
    }

    public void setTblNatillera(TblNatillera tblNatillera) {
        this.tblNatillera = tblNatillera;
    }

    public TblEstado getEstado() {
        return estado;
    }

    public void setEstado(TblEstado estado) {
        this.estado = estado;
    }

    public TblUsuario getTblUsuario() {
        return tblUsuario;
    }

    public void setTblUsuario(TblUsuario tblUsuario) {
        this.tblUsuario = tblUsuario;
    }

    public List<TblCuota> getTblCuotaList() {
        return tblCuotaList;
    }

    public void setTblCuotaList(List<TblCuota> tblCuotaList) {
        this.tblCuotaList = tblCuotaList;
    }

    public List<TblPrestamo> getTblPrestamoList() {
        return tblPrestamoList;
    }

    public void setTblPrestamoList(List<TblPrestamo> tblPrestamoList) {
        this.tblPrestamoList = tblPrestamoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tblNatilleraPersonaPK != null ? tblNatilleraPersonaPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TblNatilleraPersona)) {
            return false;
        }
        TblNatilleraPersona other = (TblNatilleraPersona) object;
        if ((this.tblNatilleraPersonaPK == null && other.tblNatilleraPersonaPK != null) || (this.tblNatilleraPersonaPK != null && !this.tblNatilleraPersonaPK.equals(other.tblNatilleraPersonaPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "" + tblNatilleraPersonaPK;
    }
    
}
